﻿using System;
using System.Reflection;

namespace Nomad.ASPMVVM {
    public static class AssemblyExtensions {
        public static TInterface CreateInstanceOf<TInterface>(this Assembly assembly, string typeName) {
            var interfaceType = typeof(TInterface);
            var instance = assembly.CreateInstance(typeName);
            if (instance is TInterface) {
                return (TInterface)instance;
            } else {
                throw new NotImplementedException(String.Format(Properties.Resources.NotImplementedExceptionMessage, interfaceType.FullName));
            }
        }
    }
}
